<script setup lang="ts">
import { useData } from 'vitepress';
import { computed, inject, Ref } from 'vue';
import VPFeatures from './VPFeatures.vue';

const { frontmatter: fm } = useData();
const curTheme = inject('current-theme') as Ref<string>;
const isLargeSize = inject('is-large') as Ref<boolean>;
</script>

<template>
    <div class="farris-doc-feature-wrapper">
        <slot name="before-feature"></slot>
        <div :class="['farris-doc-feature',isLargeSize?'':'feature-small-size']" >
            <div class="farris-doc-feature--left" v-if="isLargeSize">
                <div class="farris-doc-feature--header">
                    <slot name="feature-group-001"></slot>
                    <slot name="feature-group-002"></slot>
                    <slot name="feature-group-003"></slot>
                </div>
            </div>
            <div class="farris-doc-feature--right">
                <div class="farris-doc-feature--row">
                    <div class="farris-doc-feature--header" v-if="!isLargeSize">
                        <slot name="feature-group-001"></slot>
                    </div>
                    <div class="farris-doc-feature--content feature-group-001">
                        <div class="content-bg">
                            <img src="/assets/feature-group1-001.png" v-if="curTheme != 'dark'" />
                            <img src="/assets/feature-group1-001-dark.png" v-if="curTheme == 'dark'" />
                        </div>
                        <div class="feature-container">
                            <div class="bgimg"></div>
                            <img class="base-img" src="/assets/feature-group1-002.png" />
                            <div class="animate-img-base animate-left"></div>
                            <div class="animate-img-base animate-top"></div>
                            <div class="animate-img-base animate-right"></div>
                            <div class="animate-img-base animate-center"></div>
                            <div class="animate-img-base animate-left-bottom"></div>
                            <div class="animate-img-base animate-right-bottom"></div>
                        </div>
                    </div>
                </div>
                <div class="farris-doc-feature--row">
                    <div class="farris-doc-feature--header" v-if="!isLargeSize">
                        <slot name="feature-group-002"></slot>
                    </div>
                    <div class="farris-doc-feature--content feature-group-002">
                        <div class="content-bg">
                            <img src="/assets/feature-group2-001.png" v-if="curTheme != 'dark'" />
                            <img src="/assets/feature-group2-001-dark.png" v-if="curTheme == 'dark'" />
                        </div>
                        <div class="feature-container">
                            <div class="bgimg"></div>
                            <img class="base-img" src="/assets/feature-group2-002.png" />
                            <div class="animate-img-base animate-left"></div>
                            <div class="animate-img-base animate-right"></div>
                            <div class="animate-img-base animate-bottom"></div>
                        </div>
                    </div>
                </div>
                <div class="farris-doc-feature--row">
                    <div class="farris-doc-feature--header" v-if="!isLargeSize">
                        <slot name="feature-group-003"></slot>
                    </div>
                    <div class="farris-doc-feature--content feature-group-003">
                        <div class="content-bg">
                            <img src="/assets/feature-group3-001.png" v-if="curTheme != 'dark'" />
                            <img src="/assets/feature-group3-001-dark.png" v-if="curTheme == 'dark'" />
                        </div>
                        <div class="feature-container">
                            <div class="bgimg"></div>
                            <img class="base-img" src="/assets/feature-group3-002.png" />
                            <div class="animate-img-base animate-left"></div>
                            <div class="animate-img-base animate-top"></div>
                            <div class="animate-img-base animate-right"></div>
                            <div class="animate-img-base animate-right-bottom"></div>
                            <div class="animate-img-base animate-left-bottom"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <slot name="after-feature"></slot>
    </div>
</template>

<style scoped>
.feature-container {
    height: 100%;
    position: relative;
    box-shadow: 0px 0px 16px 0px rgba(49, 60, 73, 0.2);
    border-radius: 22px;
}
.dark .feature-container {
    box-shadow: none;
}
.dark .feature-container::before {
    display: none;
}
.feature-container::before {
    content: '';
    position: absolute;
    border-radius: 22px;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(33px);
}

.farris-doc-feature--content {
    height: 60vh;
    position: relative;
    max-height: 455px;
    max-width: 788px;
    width: 90%;
    margin: 0 auto;
}

.farris-doc-feature--content .content-bg {
    width: 60%;
    position: absolute;
    left: 0;
    animation-duration: 0.3s;
    animation-timing-function: ease;
    top: -100px;
    z-index: -1;
}
.dark .farris-doc-feature--content .content-bg {
    width: 120%;
    left: -100px;
    top: -150px;
}

.feature-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-container .base-img {
    position: relative;
    z-index: 20;
}
.animate-img .feature-container .animate-img-base {
    opacity: 1;
}
.feature-container .animate-img-base {
    position: absolute;
    z-index: 30;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
}

.animate-img .feature-container .animate-img-base {
    animation-duration: 0.5s;
    animation-timing-function: ease-out;
}

.farris-doc-feature-wrapper {
    background-image:var(--feature-main-bg);
    background-position: top center;
    background-attachment: fixed;
    background-size: contain;
    background-repeat: no-repeat;
}
/* .farris-doc-feature-wrapper::before{
    content:'';
    position:absolute;
    height:100vh;
    left:0;
    right:0;
} */

.farris-doc-feature {
    margin: 0 auto;
    display: flex;
    max-width: var(--vp-layout-max-width);
}

.farris-doc-feature--header {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.farris-doc-feature--header .feature-header {
    padding: 0 0 0 40px;
    position: relative;
}

.farris-doc-feature.fixed .feature-header.inb-animate-slideInUp {
    visibility: visible !important;
}

.farris-doc-feature .farris-doc-feature--right {
    position: relative;
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    height: calc(300vh - 60px);
    flex: 1 1 0;
}

.farris-doc-feature--left {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: calc(300vh - 60px);
    min-width: 405px;
}
.farris-doc-feature.fixed {
    display: block;
}
.farris-doc-feature.fixed .farris-doc-feature--left {
    position: fixed;
    top: 60px;
    height: calc(100vh - 60px);
    /* transform: translateX(-100%);*/
}
.farris-doc-feature.fixed .farris-doc-feature--header {
    height: 233px;
}

.farris-doc-feature.fixed .farris-doc-feature--right {
    margin-left: 405px;
}
/**小尺寸下 */
.feature-small-size  .farris-doc-feature--right{
    height:auto;
    display: block;
    width:100%;
}
.feature-small-size  .farris-doc-feature--header{
    height:auto;
    width: 90%;
    margin: 0 auto;
}
.feature-small-size  .farris-doc-feature--content{
    margin-top:150px;
    margin-bottom:150px;
}

/**第二个特性 */
.feature-group-002 .animate-left {
    width: 191px;
    height: 181px;
    background-image: var(--feature-group-002-animate-left);
}

.feature-group-002 .animate-right {
    width: 214px;
    height: 197px;
    background-image: var(--feature-group-002-animate-right);
}

.feature-group-002 .animate-bottom {
    width: 199px;
    height: 203px;
    background-image: var(--feature-group-002-animate-bottom);
}

/**第三个特性 */
.feature-group-003 .animate-left {
    width: 193px;
    height: 209px;
    background-image: var(--feature-group-003-animate-left);
}

.feature-group-003 .animate-top {
    width: 197px;
    height: 171px;
    background-image: var(--feature-group-003-animate-top);
}

.feature-group-003 .animate-right {
    width: 188px;
    height: 220px;
    background-image: var(--feature-group-003-animate-right);
}

.feature-group-003 .animate-right-bottom {
    width: 168px;
    height: 183px;
    background-image: var(--feature-group-003-animate-right-bottom);
}

.feature-group-003 .animate-left-bottom {
    width: 201px;
    height: 170px;
    background-image: var(--feature-group-003-animate-left-bottom);
}

/** */
.dark .feature-container .bgimg {
    display: none;
}
.feature-container .bgimg {
    position: absolute;
    top: 0px;
    left: 0px;
    bottom: 0px;
    right: 0px;
    z-index: 1;
    background: url('/assets/feature-group1-bg.png') no-repeat center;
    background-size: cover;
}

.feature-group-001 .animate-left {
    width: 198px;
    height: 154px;
    background-image: var(--feature-group-001-animate-left);
}

.feature-group-001 .animate-top {
    width: 198px;
    height: 154px;
    background-image: var(--feature-group-001-animate-top);
}
.feature-group-001 .animate-right {
    width: 148px;
    height: 131px;
    background-image: var(--feature-group-001-animate-right);
}
.feature-group-001 .animate-center {
    width: 198px;
    height: 132px;
    background-image: var(--feature-group-001-animate-center);
}
.feature-group-001 .animate-right-bottom {
    width: 198px;
    height: 154px;
    background-image: var(--feature-group-001-animate-right-bottom);
}

.feature-group-001 .animate-left-bottom {
    width: 198px;
    height: 154px;
    background-image: var(--feature-group-001-animate-left-bottom);
}

/**动画 */
.animate-img .feature-container .animate-left {
    left: 0%;
    top: 15%;
    animation-name: animate-left;
}

.animate-img .feature-container .animate-top {
    left: 25%;
    top: 0%;
    animation-name: animate-top;
}

.animate-img .feature-container .animate-right {
    right: 0%;
    bottom: 50%;
    animation-name: animate-right;
}
.animate-img .feature-container .animate-center {
    top: 30%;
    left: 50%;
    animation-name: animate-center;
}

.animate-img .feature-container .animate-right-bottom {
    right: 15%;
    bottom: 0%;
    animation-name: animate-right-bottom;
}

.animate-img .feature-container .animate-left-bottom {
    left: 15%;
    bottom: 0%;
    animation-name: animate-left-bottom;
}

.animate-img .feature-container .animate-bottom {
    left: 45%;
    bottom: 0%;
    animation-name: animate-bottom;
}
@media(max-width:1000px) {
    .farris-doc-feature--left{
        width:30%;
    }
    .farris-doc-feature.fixed .farris-doc-feature--right{
        margin-left:30%;
    }
}
</style>
